define(function(){
	var PopUpBox=function(initConfig){
		initConfig=$.getDefined(initConfig || {});

		function popUpBoxTypeConfigInit(popUpBoxType){
			function typeInitConfigAttr(typeInitConfig){
				$.each(typeInitConfig, function(k,v) {
					initConfig[k]=$.getDefined(initConfig[k],v);
				});

			}
			switch (popUpBoxType){
				case 'alert':
					typeInitConfigAttr({
						'closeBtn':			false
					});
					break;
				case 'confirm':
					typeInitConfigAttr({
						'closeBtn':			false,
						'submitBtnType':	'confirm'
					});
					break;
				case 'html':
				case 'dom':
				case 'iframe':
					typeInitConfigAttr({
						'submitBtnType':	'confirm'
					});
					break;
				case 'bubble':
				case 'menu':
					typeInitConfigAttr({
						'titleText':		false,
						'bgShow':			false,
						'bgClose':			true,
						'bgBlur':			false,
						'closeBtn':			false,
						'closeClear':		false,
						'submitBtnType':	false,
						'focus':			false
					});
					break;
				case 'tips':
				case 'textTips':
					typeInitConfigAttr({
						'titleText':		false,
						'bgShow':			false,
						'bgClose':			false,
						'bgBlur':			false,
						'closeBtn':			false,
						'closeTime':		15000,
						'submitBtnType':	false
					});
					break;
				case 'wait':
					typeInitConfigAttr({
						'titleText':		false,
						'bgShow':			true,
						'bgClose':			false,
						'closeBtn':			false,
						'submitBtnType':	false
					});
					break;
				default:
					typeInitConfigAttr({});
					console.error('con`t find this popupbox type:',popUpBox.config.type)

			}
		}







		var popUpBox=this;
		popUpBox.config={
			titleHeight:40,
			footerBarHeight:58
		};
		popUpBox.$dom=$('<div class="popUpBox selectDisabled" tabindex="0"></div>');
		popUpBox.$dom[0].popUpBox=popUpBox;
		var $body=$('body');


		popUpBox.config.type			=$.getDefined(	initConfig.type,			'alert');

		popUpBoxTypeConfigInit(popUpBox.config.type)

		popUpBox.config.titleText		=$.getDefined(	initConfig.titleText,		'提示');
		popUpBox.config.content			=$.getDefined(	initConfig.content,			false);
		popUpBox.config.submitBtnType	=$.getDefined(	initConfig.submitBtnType,	'alert');

		popUpBox.config.submitBtnText	=$.getDefined(	initConfig.submitBtnText,	{});
		popUpBox.config.submitBtnText.yes=$.getDefined(	popUpBox.config.submitBtnText.yes,	'确定'.tr('button'));
		popUpBox.config.submitBtnText.no=$.getDefined(	popUpBox.config.submitBtnText.no,	'取消'.tr('button'));

		popUpBox.config.$parent			=$.getDefined(	initConfig.$parent,			false);

		popUpBox.config.bgShow			=$.getDefined(	initConfig.bgShow,			true);
		popUpBox.config.bgBlur			=$.getDefined(	initConfig.bgBlur,			false);

		popUpBox.config.bgClose			=$.getDefined(	initConfig.bgClose,			false);

		popUpBox.config.closeBtn		=$.getDefined(	initConfig.closeBtn,		true);
		popUpBox.config.closeTime		=$.getDefined(	initConfig.closeTime,		0);
		popUpBox.config.closeClear		=$.getDefined(	initConfig.closeClear,		true);

		popUpBox.config.show			=$.getDefined(	initConfig.show,			false);
		popUpBox.config.focus			=$.getDefined(	initConfig.focus,			true);

		popUpBox.config.$mouseEnterShow	=$.getDefined(	initConfig.$mouseEnterShow,	false);
		popUpBox.config.$mouseLeaveClose=$.getDefined(	initConfig.$mouseLeaveClose,false);
		popUpBox.config.$clickShow		=$.getDefined(	initConfig.$clickShow,		false);

		popUpBox.config.zIndexTop		=$.getDefined(	initConfig.zIndexTop,		true);

		popUpBox.config.position		=$.getDefined(	initConfig.position,		{});

		popUpBox.config.follow			=$.getDefined(	initConfig.follow,			{});

		if(popUpBox.config.follow.$dom){
			popUpBox.config.follow.dom=popUpBox.config.follow.$dom[0];
		}else if(popUpBox.config.follow.dom){
			popUpBox.config.follow.$dom=$(popUpBox.config.follow.dom);
		}else{
			popUpBox.config.follow.$dom=false;
			popUpBox.config.follow.dom=false;
		}

		popUpBox.config.follow.direction=$.getDefined(	popUpBox.config.follow.direction,'center bottom');
		popUpBox.config.bubbleArrow		=$.getDefined(	initConfig.bubbleArrow,		false);

		popUpBox.config.edge			=$.getDefined(	initConfig.edge,			false);
		popUpBox.config.drag			=$.getDefined(	initConfig.drag,			false);
		popUpBox.config.parentScroll	=$.getDefined(	initConfig.parentScroll,	true);
		popUpBox.config.positionAbsolute=$.getDefined(	initConfig.positionAbsolute,false);

		popUpBox.config.keyClose		=$.getDefined(	initConfig.keyClose,		true);
		popUpBox.config.keySubmit		=$.getDefined(	initConfig.keySubmit,		true);

		popUpBox.callback				=$.getDefined(	initConfig.callback,			{});
		popUpBox.callback.show			=$.getDefined(	popUpBox.callback.show,			function(){});
		popUpBox.callback.showBefore	=$.getDefined(	popUpBox.callback.showBefore,	function(){});
		popUpBox.callback.showAfter		=$.getDefined(	popUpBox.callback.showAfter,	function(){});
		popUpBox.callback.close			=$.getDefined(	popUpBox.callback.close,		function(){});
		popUpBox.callback.closeBefore	=$.getDefined(	popUpBox.callback.closeBefore,	function(){});
		popUpBox.callback.closeAfter	=$.getDefined(	popUpBox.callback.closeAfter,	function(){});
		popUpBox.callback.yes			=$.getDefined(	popUpBox.callback.yes,			function(){});
		popUpBox.callback.yesBefore		=$.getDefined(	popUpBox.callback.yesBefore,	function(){});
		popUpBox.callback.yesAfter		=$.getDefined(	popUpBox.callback.yesAfter,		function(){});
		popUpBox.callback.no			=$.getDefined(	popUpBox.callback.no,			function(){});
		popUpBox.callback.noBefore		=$.getDefined(	popUpBox.callback.noBefore,		function(){});
		popUpBox.callback.noAfter		=$.getDefined(	popUpBox.callback.noAfter,		function(){});

		popUpBox.$dom.addClass(popUpBox.config.type);
		if(initConfig.style!==undefined){
			if(typeof(initConfig.style)==='string'){
				popUpBox.$dom.addClass(initConfig.style);
			}else{
				popUpBox.$dom.css(initConfig.style);
			}
		}

		popUpBox.config.clickOutClose=(popUpBox.config.bgClose===true && popUpBox.config.bgShow===false);



		popUpBox.$background=$('<div class="popUpBoxBg" style="display:none;"></div>').appendTo(popUpBox.$dom);



		popUpBox.$background.on('click',function(){
			if(popUpBox.config.bgClose===true){
				popUpBox.close();
			}
		});
		if(popUpBox.config.bgShow){
			popUpBox.$background.show();
		}



		popUpBox.$main=$('<div class="popUpBoxFg"></div>').appendTo(popUpBox.$dom);

		popUpBox.$title=$('<div class="popUpBoxTitle"></div>').appendTo(popUpBox.$main);

		popUpBox.$title.on('mousedown',function(e){
			if(popUpBox.config.drag){
				window.windowDrag.dragStart(popUpBox.$positionBox,e);
			}
		}).on('mouseup',function(e){
			if(popUpBox.config.drag && window.windowDrag.$dragDom){
				window.windowDrag.moveStop();
			}
		});

		if(popUpBox.config.titleText!==false){
			popUpBox.$title.html(popUpBox.config.titleText);
		}else{
			popUpBox.$dom.addClass('noTitleBar');
		}

		popUpBox.$content=$('<div class="popUpBoxContent"></div>').appendTo(popUpBox.$main);
		popUpBox.$bubbleArrow=$('<div class="bubbleArrow"></div>').appendTo(popUpBox.$main);
		if(popUpBox.config.bubbleArrow!==false && popUpBox.config.bubbleArrow!=='auto'){
			popUpBox.$bubbleArrow.addClass(popUpBox.config.bubbleArrow);
		}

		popUpBox.contentUpdate=function(contentData){
			if(contentData===undefined){
				contentData=popUpBox.config.content
			}else{
				popUpBox.config.content=contentData;
			}

			popUpBox.$content.html('');
			function loadHtml(htmlUrl){
				popUpBox.$content.load(htmlUrl,function(res,status,req){
					if(status=='success'){
						StringTranslate.$dom(popUpBox.$content)
					}
				});
			}
			function loadIframe(iframeSrc){
				popUpBox.$content.html('<iframe width="100%" height="100%" frameborder="0" src="'+iframeSrc+'"></iframe>');
			}
			function addMenuList(menuListData){
				var $menuBtnList=$('<ul class="menuBtnBox"></ul>');
				function MenuBtn(menuBtnData){
					var menuBtn=this;
					menuBtn.data=menuListData;
					menuBtn.config={};
					menuBtn.config.callback={
						//mousedown:function(){},
						//mouseup:function(){},
						click:function(){}
					}
					if(menuBtnData.callback!==undefined){
						if(typeof menuBtnData.callback ==='function'){
							menuBtn.config.callback.click=menuBtnData.callback;
						}else{
							menuBtn.config.callback=menuBtnData.callback;
						}
					}

					menuBtn.$dom=$('<li class="menuBtn">'+menuBtnData.text+'</li>');

					$.each(menuBtn.config.callback, function(eventName,eventFn) {
						menuBtn.$dom.on(eventName,function(e){
							var eventResult=eventFn(e,menuBtn);
							if(eventName==='click' && eventResult!==false){
								popUpBox.close();
							}
						})
					});

				}
				$.each(menuListData,function(i,menuBtnData){
					var menuBtn=new MenuBtn(menuBtnData);
					$menuBtnList.append(menuBtn.$dom);
				});
				$menuBtnList.appendTo(popUpBox.$content);
				//$('<div class="menuArrow"></div>').appendTo(popUpBox.$content);
			}
			function addHoverTips(tipsContent){
				popUpBox.$content.html(tipsContent);
				//$('<div class="menuArrow"></div>').appendTo(popUpBox.$content);
			}
			switch(popUpBox.config.type){
				case 'html':
					loadHtml(contentData);
					break;
				case 'iframe':
					loadIframe(contentData);
					break;
				case 'menu':
					addMenuList(contentData);
					break;
				default:
					popUpBox.$content.html(contentData);

			}
		}
		if(popUpBox.config.content!==false){
			popUpBox.contentUpdate();
		}




		popUpBox.submitYes=function(){
			if(popUpBox.callback.yesBefore(popUpBox)===false){
				return false;
			}
			if(popUpBox.callback.yes(popUpBox)===false){
				return false;
			}
			if(popUpBox.callback.yesAfter(popUpBox)===false){
				return false;
			}
			popUpBox.close();
		}

		popUpBox.submitNo=function(){
			if(popUpBox.callback.noBefore(popUpBox)===false){
				return false;
			}
			if(popUpBox.callback.no(popUpBox)===false){
				return false;
			}
			if(popUpBox.callback.noAfter(popUpBox)===false){
				return false;
			}
			popUpBox.close();
		}
		function SubmitBtnBox(){
			var btnBox=this;
			btnBox.$dom=$('<div class="submitBtnBox"></div>');

			btnBox.$noCol=$('<div class="col"></div>').appendTo(btnBox.$dom);
			btnBox.$noBtn=$('<div class="btn btn-default"></div>').appendTo(btnBox.$noCol);
			btnBox.$noBtn.html(popUpBox.config.submitBtnText.no);
			btnBox.$noBtn.on('click',function(){
				popUpBox.submitNo();
			});

			btnBox.$yesCol=$('<div class="col"></div>').appendTo(btnBox.$dom);
			btnBox.$yesBtn=$('<div class="btn btn-primary"></div>').appendTo(btnBox.$yesCol);
			btnBox.$yesBtn.html(popUpBox.config.submitBtnText.yes);
			btnBox.$yesBtn.on('click',function(){
				popUpBox.submitYes();
			});

			if(popUpBox.config.submitBtnType==='alert'){
				btnBox.$noCol.hide();
			}

		}

		popUpBox.submitBtnBox=new SubmitBtnBox();
		popUpBox.submitBtnBox.$dom.appendTo(popUpBox.$main);

		if(popUpBox.config.submitBtnType===false){
			popUpBox.$dom.addClass('noSubmitBtn');
		}else{
			popUpBox.submitBtnBox.$dom.addClass(popUpBox.config.submitBtnType);
		}

		popUpBox.$closeBtn=$('<input type="button" class="close" value="×" />').appendTo(popUpBox.$main);
		popUpBox.$closeBtn.on('click',function(){
			popUpBox.close();
		});

		if(popUpBox.config.closeBtn===false){
			popUpBox.$dom.addClass('noCloseBtn');
		}

		popUpBox.setPosition=function (){
			var $positionBox;
			if(popUpBox.config.bgShow){
				popUpBox.$dom.css({
				    'width': '100%',
				    'height': '100%',
				    'left': 0,
				    'top': 0
				});
				$positionBox=popUpBox.$main;
				popUpBox.$main.css('position','absolute');
			}else{
				$positionBox=popUpBox.$dom;
				popUpBox.$main.css('position','relative');
			}
			if(popUpBox.config.positionAbsolute===true){
				$positionBox.css({
				    'position': 'absolute'
				});
			}
			popUpBox.$positionBox=$positionBox;
			var positionBoxDom=$positionBox[0];
			//follow
			var postionBoxOuterSize={
				width:$positionBox.outerWidth(),
				height:$positionBox.outerHeight()
			}
			function positionFollow(){
				if(!popUpBox.config.follow.dom){
					console.error('popUpBox.config.follow.dom undefined!');
					return false;
				}
				var $followDom=popUpBox.config.follow.$dom,
					followDom=popUpBox.config.follow.dom;
				if(popUpBox.config.type==='menu'){
					popUpBox.$content.css('min-width',$followDom.outerWidth());
				}
				var followDomClientRect={};
				if(popUpBox.config.positionAbsolute===true){
					followDomClientRect=$followDom.offset();
					followDomClientRect.right=followDomClientRect.left+$followDom.outerWidth();
					followDomClientRect.bottom=followDomClientRect.top+$followDom.outerHeight();
				}else{
					followDomClientRect=followDom.getBoundingClientRect()
				}
				var followDirectionArr=popUpBox.config.follow.direction.split(' ');
				var followDirection={};
				switch(followDirectionArr[0]){
					case 'left':
						followDirection.x=1;
						break;
					case 'center':
						followDirection.x=2;
						break;
					case 'right':
						followDirection.x=4;
						break;
				}
				switch(followDirectionArr[1]){
					case 'top':
						followDirection.y=1;
						break;
					case 'middle':
						followDirection.y=2;
						break;
					case 'bottom':
						followDirection.y=4;
						break;
				}
				function setPositionBoxFollow(followX,followY){
					var followStyle={};
					switch(followX){
						case 1://left left 弹窗右侧和目标左侧对齐
							followStyle['left']=followDomClientRect.left-postionBoxOuterSize.width;
							followStyle['margin-left']=0;
							break;
						case 2://rigt left 弹窗左侧和目标左侧对齐
							followStyle['left']=followDomClientRect.left;
							followStyle['margin-left']=0;
							break;
						case 3://left right 弹窗右侧和目标右侧对齐
							followStyle['left']=followDomClientRect.right-postionBoxOuterSize.width;
							followStyle['margin-left']=0;
							break;
						case 4://right right 弹窗左侧和目标右侧对齐
							followStyle['left']=followDomClientRect.right;
							followStyle['margin-left']=0;
							break;
					}
					if(followX==2 || followX==3){
						if(followY==2 || followY==3){
							followY=1;
						}
					}
					switch(followY){
						case 1://top top 弹窗底部和目标顶对齐
							followStyle['top']=followDomClientRect.top-postionBoxOuterSize.height;
							followStyle['margin-top']=0;
							break;
						case 2://top bottom 弹窗顶部和目标顶部对齐
							followStyle['top']=followDomClientRect.top;
							followStyle['margin-top']=0;
							break;
						case 3://bottom top 弹窗底部和目标底部对齐
							followStyle['top']=followDomClientRect.bottom-postionBoxOuterSize.height;
							followStyle['margin-top']=0;
							break;
						case 4://bottom bottom 弹窗顶部和目标底部对齐
							followStyle['top']=followDomClientRect.bottom;
							followStyle['margin-top']=0;
							break;
					}
					$positionBox.css(followStyle);
					if(popUpBox.config.bubbleArrow==='auto'){
						switch(followY){
							case 1:
								popUpBox.$bubbleArrow.attr('class','bubbleArrow bottom');
								break;
							case 4:
								popUpBox.$bubbleArrow.attr('class','bubbleArrow top');
								break;
						}
					}
					/*function edgeOverflowAuto(){
						//setPositionBoxFollow(followX,followY);
						var hasOverflow=false;
						var overflowRight=positionBoxDom.getBoundingClientRect().right-$(window).width();
						if(overflowRight>0){
							hasOverflow=true;
							followStyle['left']-=overflowRight;
						}
						var overflowBottom=positionBoxDom.getBoundingClientRect().bottom-$(window).height();
						if(overflowBottom>0){
							hasOverflow=true;
							followStyle['top']-=overflowBottom;
						}
						if(hasOverflow){
							$positionBox.css(followStyle);
						}
					}
					edgeOverflowAuto();*/
				}
				var edgeOverflowAutoRunTime=0;
				function edgeOverflowAuto(followX,followY){
					setPositionBoxFollow(followX,followY);
					edgeOverflowAutoRunTime++;
					var hasOverflow=false;
					var newClientRect=positionBoxDom.getBoundingClientRect();
					var overflowRight=newClientRect.right-$(window).width();
					if(overflowRight>0){
						hasOverflow=true;
						followX--;
					}
					var overflowLeft=newClientRect.left;
					if(overflowLeft<0){
						hasOverflow=true;
						followX--;
					}
					var overflowBottom=newClientRect.bottom-$(window).height();
					if(overflowBottom>0){
						hasOverflow=true;
						followY--
					}
					var overflowTop=newClientRect.top;
					if(overflowTop<0){
						hasOverflow=true;
						followY--
					}
					if(hasOverflow && edgeOverflowAutoRunTime<5){
						if(followX<1){
							followX=4;
						}
						if(followY<1){
							followY=4;
						}
						edgeOverflowAuto(followX,followY);
					}
				}
				edgeOverflowAuto(followDirection.x,followDirection.y);
				//setPositionBoxFollow(followDirection.x,followDirection.y);
				$positionBox.css(popUpBox.config.position);
			}
			function positionAuto(){
				$positionBox.css(popUpBox.config.position);
				if(
					popUpBox.config.position.left===undefined &&
					popUpBox.config.position.right===undefined
				){
					$positionBox.css({
						'left':'50%',
						'margin-left':-$positionBox.outerWidth()/2
					});
				}
				if(
					popUpBox.config.position.top===undefined &&
					popUpBox.config.position.bottom===undefined
				){
					$positionBox.css({
						'top':'50%',
						'margin-top':-$positionBox.outerHeight()/2
					});
				}
				function windowEdgeCheck(){
					var popUpBoxOverflowRight=positionBoxDom.getBoundingClientRect().right-$(window).width();
					if(popUpBoxOverflowRight>0){
						var baseMarginLeft=$.parseInt($positionBox.css('margin-left'));
						$positionBox.css({
							'margin-left':baseMarginLeft-popUpBoxOverflowRight-10
						});
					}
					var overflowBottom=positionBoxDom.getBoundingClientRect().bottom-$(window).height();
					if(overflowBottom>0){
						var baseMarginTop=$.parseInt($positionBox.css('margin-top'));
						$positionBox.css({
							'margin-top':baseMarginTop-overflowBottom-10
						});
					}
				}
				if(popUpBox.config.edge==='auto'){
					windowEdgeCheck();
				}
			}
			if(popUpBox.config.follow.dom!==false){
				positionFollow();
			}else{
				positionAuto();
			}
		}
		if(popUpBox.config.$parent===false){
			popUpBox.config.$parent=$body;
			popUpBox.config.$overflowWindow=$('html');
		}else{
			popUpBox.config.$overflowWindow=popUpBox.config.$parent;
		}




		function clickBodyClose(e){
			popUpBox.close();
		}
		if(popUpBox.config.clickOutClose){
			popUpBox.$dom.on('mousedown',function(e){
				e.stopPropagation();
			});
		}

		popUpBox.display=function(newDisplayStatus){
			function displayTrue(){
				if(popUpBox.callback.showBefore(popUpBox)===false){
					return false;
				}
				if(popUpBox.config.parentScroll===false){
					popUpBox.config.$overflowWindow.css({'overflow': 'hidden'});
				}
				popUpBox.$dom.appendTo(popUpBox.config.$parent);
				if(popUpBox.config.type==='wait'){
					popUpBox.$dom.stop(false,false).fadeIn();
				}else{
					popUpBox.$dom.show();
				}
				popUpBox.callback.show(popUpBox);
				if(popUpBox.config.clickOutClose){
					$body.on('mousedown',clickBodyClose);
				}
				if(popUpBox.config.focus){
					popUpBox.$dom.focus();
				}
				if(popUpBox.config.zIndexTop){
					$.zIndexTop(popUpBox.$dom);
				}
				popUpBox.setPosition();
				popUpBox.callback.showAfter(popUpBox);
				//timeOutClose();
			}
			function displayFalse(){
				if(popUpBox.callback.closeBefore(popUpBox)===false){
					return false;
				}
				if(popUpBox.callback.close(popUpBox)===false){
					return false;
				}
				if(popUpBox.config.clickOutClose){
					$body.off('mousedown',clickBodyClose);
				}
				if(popUpBox.config.type==='wait'){
					popUpBox.$dom.stop(false,false).fadeOut(function(){
						boxDomCloseAndRemove();
					});
				}else{
					boxDomCloseAndRemove();
				}
			}
			function boxDomCloseAndRemove(){
				if(popUpBox.config.closeClear===true){
					popUpBox.$dom.remove();
				}else{
					popUpBox.$dom.detach();
				}
				if($('body').children('.popUpBox').length<1){
					$('html').css('overflow','');
				}
				popUpBox.callback.closeAfter(popUpBox);
			}
			/*function timeOutClose(){
				if(popUpBox.config.closeTime>0){

					setTimeout(function(){
						displayFalse();
					},popUpBox.config.closeTime);
				}
			}*/
			if(newDisplayStatus!==popUpBox.config.show){
				popUpBox.config.show=newDisplayStatus;
				if(popUpBox.config.show===true){
					displayTrue();
				}else{
					displayFalse();
				}
			}
		}

		popUpBox.close=function(){
			if(popUpBox.config.bgBlur===true){
				popUpBox.$dom.siblings().removeClass('box-blur');
			}
			popUpBox.display(false);
		}

		popUpBox.timeoutClose=function(toClose,outTime){
			outTime=$.getDefined(outTime,100);
			clearTimeout(popUpBox.closeTimeout);
			if(toClose){
				popUpBox.closeTimeout=setTimeout(function(){
					popUpBox.close();
				},outTime);
			}
		}
		popUpBox.show=function(){
			popUpBox.display(true);
			if(popUpBox.config.bgBlur===true){
				popUpBox.$dom.siblings().addClass('box-blur');
			}
			if(popUpBox.config.closeTime>0){
				popUpBox.timeoutClose(true,popUpBox.config.closeTime);
			}
		}

		if(popUpBox.config.$mouseEnterShow!==false){
			popUpBox.config.$mouseEnterShow.on('mouseenter',function(){
				popUpBox.timeoutClose(false);
				popUpBox.show();
			})
		}
		if(popUpBox.config.$clickShow!==false){
			popUpBox.config.$clickShow.on('click',function(){
				popUpBox.show();
			})
		}



		if(popUpBox.config.$mouseLeaveClose!==false){
			popUpBox.config.$mouseLeaveClose.on('mouseleave',function(){
				popUpBox.timeoutClose(true);
			});
			popUpBox.$dom.on('mouseenter',function(){
				popUpBox.timeoutClose(false);
			}).on('mouseleave',function(){
				popUpBox.timeoutClose(true);
			});
		}


		popUpBox.$dom.on('keyup',function(e){
			if(e.keyCode===13 && popUpBox.config.keySubmit){
				popUpBox.submitYes();
			}
			if(e.keyCode===27 && popUpBox.config.keyClose){
				popUpBox.close();
			}
		});
		if(popUpBox.config.show){
			popUpBox.config.show=false;
			popUpBox.show();
		}

	}

    var tipsPopUpBox=new PopUpBox({
		'type':'tips',
		'style':'black',
		'content':'',
		'focus':false,
		'closeTime':false
	});
	var tipsCloseTimeout;
    var _Tips=function(str){
    	tipsPopUpBox.$content.html(str);
    	tipsPopUpBox.show();
    	clearTimeout(tipsCloseTimeout);
    	tipsCloseTimeout=setTimeout(function(){
    		tipsPopUpBox.close();
    	},3000);
	}
    var _Alert=function(tt,ct,cb){
		var myPopUpBox=new PopUpBox({
			'type':'alert',
			'show':true,
			'style':'textContent',
			'titleText':tt,
			'content':ct,
			'callback':{
				'yes':function(){
					if(cb){
						cb();
					}
				}
			},
			'position':{
				'width':400
			}
		});
	}

	var _Confirm = function (tt, ct, cb) {
		var popUpBox = new PopUpBox({
			type: 'dom',
			style: 'default contentScroll',
			submitBtnType: 'confirm',
			titleText: tt||'系统消息',
			show: true,
			content: '<div style="padding:30px">'+ ct +'</div>',
			callback: {
				 yes: function (e) {
					 cb && cb()
				 }
			},
			position: {
				 width: 420,
				 height: 200
			}
		})
	}


    var waitingPopUpBox=new PopUpBox({
		'type':'wait',
		'style':'black',
		'content':'Waiting...',
		'position':{
			width:230,
			height:200
		}
	});
	var waitingCloseKeyword='';
    var _Waiting=new function(){
    	var _w=this;
    	_w.show=function(tipsStr,closeKeyword){
    		//console.error('waiting open!');
    		tipsStr=tipsStr || 'Waiting...';
    		waitingPopUpBox.$content.html(tipsStr);
    		waitingPopUpBox.show();
    		if(waitingCloseKeyword=='' && closeKeyword!==undefined){
    			waitingCloseKeyword=closeKeyword;
    		}
    	}
    	_w.close=function(closeKeyword){
    		if(waitingCloseKeyword!==''){
    			if(closeKeyword===waitingCloseKeyword){
    				waitingCloseKeyword='';
    			}else{
    				return false;
    			}
    		}
			waitingPopUpBox.close();
    	}
    }
	window.PopUpBox=PopUpBox;
	window._Tips=_Tips;
	window._Alert=_Alert;
	window._Confirm=_Confirm;
	window._Waiting=_Waiting;
	return PopUpBox;
})
